package com.cpi.cornpp.corntypes.services;

import java.util.List;

import com.cpi.cornpp.common.exception.CornPPException;
import com.cpi.cornpp.corntypes.converter.CornTypesConverter;
import com.cpi.cornpp.corntypes.dao.CornTypesDAO;
import com.cpi.cornpp.corntypes.exception.CornTypesException;
/**
 * Corn Types Service
 * 
 * @author Edgar Joao
 *
 */
public class CornTypesService {
	/**
	 * Obtiene una lista de tipos de Maiz
	 * 
	 * @author Edgar Joao
	 * @return
	 * @throws CornTypesException
	 */
	public List getListCornTypes() throws CornTypesException {		
		CornTypesDAO cornTypesDAO = null;
		CornTypesConverter converter = null;		
		List cornTypesList = null;
		try{
			cornTypesDAO = new CornTypesDAO();
			converter = new CornTypesConverter();			
			cornTypesList = converter.convertDTOsToViews(cornTypesDAO.getListCornTypes());
		} catch (CornTypesException cornTypesException) {
			throw cornTypesException;
		} catch (Exception e){
			CornTypesException cornTypesException = null;
			e.printStackTrace(System.out);
			cornTypesException = new CornTypesException(e , CornPPException.LAYER_SERVICE,CornPPException.ACTION_LISTS);
			throw cornTypesException;
		}	
		return cornTypesList;	
	}
}
